import { Injectable } from '@nestjs/common';
import { Cat } from '../interfaces/cat.interface';

// 只是增加了metadata 告诉Nest这是一个Provider而已
@Injectable()
export class CatsService {
  private readonly cats: Cat[] = [];

  create(cat: Cat) {
    this.cats.push(cat);
    console.log(cat)
    console.log(this.cats);
  }

  findAll(): Cat[] {
    return this.cats;
  }
}

// 可选Provider
// @Injectable()
// export class HttpService<T> {
//   constructor(@Optional() @Inject('HTTP_OPTIONS') private httpClient: T) {}
// }
